<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use DB;

class AddressController extends Controller
{
    public function destroy($id)
    {
        $row=DB::table('address')->where('id',$id)->delete();
        if ($row>0) {
            return back();
        }
    }
    public function store(Request $request)
    {
        $data = $request->except('_token');
        $data['province']=DB::table('district')->where('id',$data['province'])->value('name');
        $data['city']=DB::table('district')->where('id',$data['city'])->value('name');
        $data['country']=DB::table('district')->where('id',$data['country'])->value('name');
        $m = DB::table('address')->insertGetId($data);
        if($m>0){
            return back();
        }
    }
}
